
S60 Platform: Sudoku Game Example
-------------------------------------------------------------------------------
   
This example demonstrates how to implement a simple custom UI game that handles
different layouts and multiple screen resolutions, and supports several input 
methods (keyboard and touch UI).

For comparison, a Flash Lite Sudoku Example with similar features is also available for download at http://www.forum.nokia.com/info/sw.nokia.com/id/8edb4149-cd63-4c8e-b47d-f3b7d73b1bba/Flash_Lite_Sudoku_Example.html

-------------------------------------------------------------------------------

PREREQUISITES

- Symbian OS key concepts.


--------------------------------------------------------------------------------

DESIGN CONSIDERATIONS

The main design goal was to implement a scalable UI, supporting different screen resolutions and input methods. In addition to scaling to different screen resolutions, the layout of UI components is also optimised for each screen.

In many devices, the screen orientation may also change once the application is running. Application scaling (orientation change) is listened for in the CSudokuAppUi::HandleResourceChangeL() method called by the application framework. CSudokuContainerControl::SizeChanged () is then called to calculate the positions and sizes of controls:

First, the biggest possible square game grid is drawn. This determines where the application logo and the statistics table can be placed. In the portrait orientation, they are placed above and below the game grid, respectively. In the landscape orientation, they are placed on the right side of the game grid. The statistics table also has two layouts, depending on the space available. The size and position of each UI element is defined in the CSudokuContainerControl::SizeChanged () method.

The position of softkeys (CBA labels) is defined in the CSudokuContainerControl::CbaSizeChanged() method. The AknLayoutUtils class is used to retrieve the active layout: portrait orientation with softkeys at the bottom, landscape orientation with softkeys at the bottom, or landscape orientation with softkeys on the right side. The exact position and size of labels is then calculated.
 
Font sizes must be calculated as dynamically as possible. In the example application, this 
is done in CSudokuContainerControl::CreateFontsL(). The font size in this case is screen width or height divided by 12.

The size of the images in the controls must also be calculated dynamically. 
The example application calculates the size of the images in the controls in the SizeChanged() method, and scales them with CGraphicEngine::SetSVGBitmapSize().

--------------------------------------------------------------------------------

IMPORTANT CLASSES

GraphicEngine.h : Creates all graphics for the application and handles graphics scaling.

SudokuGameLogic.h : Sudoku game logic class. Handles Sudoku grid data.

SudokuAppView.h : Main container UI control.

SudokuGridControl.h : Sudoku grid UI control.

SudokuBtnControl.h : Button UI control for setting values in Sudoku.

SudokuStatisticControl.h : UI control that shows game statistics.

SudokuMenuControl.h : Custom application menu.


Classes: CCoeControl, CFont, AknUtils, CFbsBitmap, CFbsBitGc, CFbsBitmapDevice.
 

--------------------------------------------------------------------------------

TOUCH UI SUPPORT

Dragging is enabled in SudokuAppView::ConstructL() with CCoeControl::EnableDragEvents().

Listening for pointer events is implemented in SudokuAppView::HandlePointerEventL().
In this kind of custom control, the base class virtual method must be implemented
in order to receive pointer events. The child UI classes CSudokuGridControl and CSudokuBtnControl listen to their own pointer events in the class HandlePointerEventL() method.

--------------------------------------------------------------------------------

KEYBOARD SUPPORT

To support non-touch UI devices, the application also handles keyboard 
events in the UI controls OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) method.

--------------------------------------------------------------------------------

RUNNING THE EXAMPLE

The example application generates a Sudoku game for the user. The user can input numbers in the game using the keyboard or a stylus. If an invalid number is used, the application highlights it and the user must try a new one.

The target of the game is to fill all grid sections with numbers.

--------------------------------------------------------------------------------

BUILD & INSTALLATION INSTRUCTIONS


MOBILE DEVICE
------------------
    Go to /Sudoku/group
    bldmake bldfiles
    abld build gcce urel
    Go to /Sudoku/sis
    Edit the paths in Sudoku_S60.pkg to match those on your development environment.

    makesis Sudoku_S60.pkg
    
    Sign the SIS package (self-signing):
        signsis Sudoku_S60.sis Sudoku_S60.sisx  YourCertificate.cer YourKey.key

    Install the signed .sisx file on an S60 3rd Edition or 5th Edition device.

EMULATOR
------------------
    Go to /Sudoku/group
    bldmake bldfiles
    abld build wins udeb

    Start the emulator.

--------------------------------------------------------------------------------

COMPATIBILITY

S60 5th Edition
S60 3rd Edition, Feature Pack 2
S60 3rd Edition, Feature Pack 1
S60 3rd Edition


Tested with: Nokia 5800 XpressMusic, Nokia E71, Nokia E90 Communicator, Nokia N95.

Created / tested with: S60 3rd Edition, MR SDK.